package com.example.teachingevaluationsystem.config.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.teachingevaluationsystem.common.ResultCode;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;

import java.util.Collection;

/**
 * @author liupeng
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@ToString
public class BaseResponse<T> {
  private T data;
  private Collection<T> list;
  private Page<T> page;
  private String message;
  private Boolean success;
  @Builder.Default private ResultCode code = ResultCode.SUCCESS;

  public boolean getSuccess() {
    return code == ResultCode.SUCCESS;
  }
}
